<?php 
namespace app\common\model;
class GoodsCate extends Common{
	protected $insert = ['addtime'=>SYS_TIME];
	protected function getStatusnameAttr($value,$data){
		return $data['status'] ? '开启' : '关闭';
	}
	protected function getAddtimeAttr($value){
		return date('Y-m-d H:i:s', $value);
	}
	protected function getCatnameAttr($value, $data){
		if ($data['pid']) {
			return $this->where('id', $data['pid'])->value('title');
		}else{
			return '顶级分类';
		}
	}
	protected function getThumbAttr($value){
		$data = explode(",", $value);
		$datas = [];
		foreach ($data as $v) {
			if(strpos($v,"http://") !== false){
				$datas[] = $v;
			}
			else{
				$datas[] = $v ? rtrim(APP_URL,"/").'/'.$v : '';
			}
		}
		return $datas;
	}
}